package com.zrfintech.common.service;

import com.google.common.base.Joiner;
import com.zrfintech.common.util.DateUtil;
import com.zrfintech.constant.CommonConstants;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 日志格式化
 * 
 * @author geyuqi
 */
public class FormatService {

    public static final String LOG_ID = "log_id";

    public static String generateLogId(String productId, String institutionId, String requestId) {
        productId = (productId == null ? "" : productId);
        institutionId = (institutionId == null ? "" : institutionId);
        requestId = (requestId == null ? "" : requestId);
        return Joiner.on(CommonConstants.JOIN_KEY).join(institutionId, productId, requestId);
    }

    public static String generateLogId() {
        String uuid = UUID.randomUUID().toString().toUpperCase().replaceAll("-", "").substring(0, 8);
        return DateUtil.format(new Date(), DateUtil.LLONG_FORMAT) + uuid;
    }


}
